package com.haonan.springboot_exercise;

import com.haonan.springboot_exercise.bean.pojo.ServicePort;
import com.haonan.springboot_exercise.dao.PopServerDao;
import com.haonan.springboot_exercise.dao.SmtpServerDao;
import com.haonan.springboot_exercise.netty.server.PopServer;
import com.haonan.springboot_exercise.netty.server.SmtpServer;
import com.haonan.springboot_exercise.util.SpringUtil;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.ComponentScans;

import java.net.InetSocketAddress;

@MapperScan("com.haonan.springboot_exercise.dao")
@SpringBootApplication

public class SpringbootExerciseApplication {

//    private static ApplicationContext applicationContext;
//    private static DefaultListableBeanFactory defaultListableBeanFactory;
    public static void main(String[] args) throws Exception {
        SpringApplication.run(SpringbootExerciseApplication.class, args);
        //发送邮件
        new Thread(()->{
            SmtpServerDao smtpServerDao = SpringUtil.getBean(SmtpServerDao.class);
            SmtpServer smtpServer = new SmtpServer();
            smtpServer.start(new InetSocketAddress("127.0.0.1", smtpServerDao.getSmtpPort("127.0.0.1")));
        }).start();
        //接收邮件
        new Thread(()->{
            PopServerDao popServerDao = SpringUtil.getBean(PopServerDao.class);
            PopServer popServer = new PopServer();
            popServer.start(new InetSocketAddress("127.0.0.1", popServerDao.getPopPort("127.0.0.1")));
        }).start();
    }
}
